package org.yue;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import org.yue.netty.servlet.ServletServer;

import javax.servlet.ServletContext;

/*
* http://stackoverflow.com/questions/32078015/spring-boot-enable-disable-embedded-tomcat-with-profile
* */
@SpringBootApplication
public class NettyServletContainerApplication {

	public static void main(String[] args) {
		System.out.println("test");
		ConfigurableApplicationContext context = SpringApplication.run(NettyServletContainerApplication.class, args);

		WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
		ServletContext servletContext = webApplicationContext.getServletContext();
		ServletServer servletServer = context.getBean(ServletServer.class);
		servletServer.init(9101,servletContext);
		servletServer.start();
	}
}
